const mongoose=require("mongoose")
//暴露第三层函数
module.exports={
    getAll3,
    create3,
    delete3
}
//获取
async function getAll3(data){
    console.log(data);
    try{
        const Alldata=await mongoose.model("loveModel")
        .find(data)
        .populate("carId");
        console.log(Alldata);
        return {
            code: 1,
            message: "获取成功",
            result:Alldata
        }
    }catch(error){
        console.log(error);
        return {
            code: 0,
            message: "获取失败"
        };
    }
}
//生成
async function create3(data){
    console.log(data);
    try{
        const Alldata=await mongoose.model("loveModel")
        .create(data)
        console.log(Alldata);
        return {
            code: 1,
            message: "生成成功",
            result:Alldata
        }
    }catch(error){
        console.log(error);
        return {
            code: 0,
            message: "获取失败"
        };
    }
}
//删除
async function delete3(data){
    // 该收藏的id
    console.log(data);
    try{
        const Alldata=await mongoose.model("loveModel")
        .deleteOne(data)
        console.log(Alldata);
        return {
            code: 1,
            message: "删除成功",
            result:Alldata
        }
    }catch(error){
        console.log(error);
        return {
            code: 0,
            message: "获取失败"
        };
    }
}